<div class="form">
<?php $form=$this->beginWidget('ActiveFormBase', array(
	'id'=>'supermod-form',
//	'enableAjaxValidation'=>true,
	//'disableAjaxValidationAttributes'=>array('SuperMod_verifyPassword'),
	'clientOptions'=>array(
		'validateOnSubmit'=>true,
	),
	'htmlOptions' => array('enctype'=>'multipart/form-data'),
));
?>
	<table class="button-form"><tr>
			<td><span class="note"><?php echo UserModule::t('Thông tin bắt buộc <span class="required">*</span>.'); ?></span></td>
			<td align="right">
				<div class="row buttons"><?php echo CHtml::submitButton($model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save')); ?></div>
			</td>
	</tr></table>
	<?php echo $form->errorSummary(array($model,$profile)); ?>
	<?php //$profileFields=$profile->getFields();?>
	
	<?php $this->beginWidget('ext.coolfieldset.JCollapsibleFieldset', array(
        'legend'=>'Thông tin tài khoản'
    )); ?>
	<div class="row">
		<?php echo $form->labelEx($model,'username'); ?>
		<?php echo $form->textField($model,'username',array('size'=>20,'maxlength'=>20)); ?>
		<?php echo $form->error($model,'username'); ?>
	</div>
	<?php if ($model->isNewRecord) :?>
	<div class="row">
		<?php echo $form->labelEx($model,'password'); ?>
		<?php echo $form->passwordField($model,'password',array('maxlength'=>128)); ?>
		<?php echo $form->error($model,'password'); ?>
	</div>
	<div class="row">
	<?php echo $form->labelEx($model,'verifyPassword'); ?>
	<?php echo $form->passwordField($model,'verifyPassword',array('maxlength'=>128)); ?>
	<?php echo $form->error($model,'verifyPassword'); ?>
	</div>
	<?php endif;?>
	<div class="row">
		<?php echo $form->labelEx($model,'email'); ?>
		<?php echo $form->textField($model,'email',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'email'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($profile,'listcourses'); ?>
		<?php echo $form->checkBoxList($profile,'listcourses',CHtml::listData(Courses::model()->findAll(), 'id', 'name'), 
											array('labelOptions' => array('style'=>'display:inline'))); ?>
		<?php echo $form->error($profile,'listcourses'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->dropDownList($model,'status',Util::itemAlias('UserStatus')); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

    <?php $this->endWidget(); ?><!-- collabsible fieldset -->

	<?php if (!$model->isNewRecord) :?>
	<script type="text/javascript">
	 $(document).ready(function(){
		 $('#SuperMod_password').change(function(){
			 $('#SuperMod_verifyPassword').val('');
		  });
	 });
	</script>
	<?php $this->beginWidget('ext.coolfieldset.JCollapsibleFieldset', array(
//		'collapsed'=>true,
        'legend'=>'Thay đổi mật khẩu'
    )); ?>
	<div class="row">
		<?php echo $form->labelEx($model,'password'); ?>
		<?php echo $form->passwordField($model,'password',array('maxlength'=>128)); ?>
		<?php echo $form->error($model,'password'); ?>
	</div>
	<div class="row">
	<?php echo $form->labelEx($model,'verifyPassword'); ?>
	<?php echo $form->passwordField($model,'verifyPassword',array('maxlength'=>128, 'value' => $model->password)); ?>
	<?php echo $form->error($model,'verifyPassword'); ?>
	</div>
	<?php $this->endWidget(); ?>
	<?php endif;?>


    <?php $this->beginWidget('ext.coolfieldset.JCollapsibleFieldset', array(
        'legend'=>'Thông tin cá nhân'
    )); ?>
		<?php
			$profileFields=$profile->getFields();
			if ($profileFields) {
				foreach($profileFields as $field) {
					if ($field->varname == 'listcourses') {
						continue;
					}
				?>
		<div class="row">
			<?php echo $form->labelEx($profile,$field->varname); ?>
			<?php
			if ($widgetEdit = $field->widgetEdit($profile)) {
				echo $widgetEdit;
			} elseif ($field->range) {
				echo $form->dropDownList($profile,$field->varname,Profile::range($field->range));
			} elseif ($field->field_type=="TEXT") {
				echo CHtml::activeTextArea($profile,$field->varname,array('rows'=>6, 'cols'=>50));
			} else {
				if ($field->varname == 'birthday')
					echo $form->textField($profile,$field->varname,array('class' => 'picker-date', 'size'=>60,'maxlength'=>(($field->field_size)?$field->field_size:255)));
				else
					echo $form->textField($profile,$field->varname,array('size'=>60,'maxlength'=>(($field->field_size)?$field->field_size:255)));
				
			}
			 ?>
			<?php echo $form->error($profile,$field->varname); ?>
		</div>
				<?php
				}
			}
		?>
	 <?php $this->endWidget(); ?><!-- collabsible fieldset -->
	<table class="button-form"><tr>
			<td align="right">
				<div class="row buttons"><?php echo CHtml::submitButton($model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save')); ?></div>
			</td>
	</tr></table>

<?php $this->endWidget(); ?>

</div><!-- form -->